package com.yihuier.yihuier.Mapper.MeetingManager;

import com.yihuier.yihuier.Entity.MeetingManager.MeetingCollection;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

@Mapper
public interface MeetingCollectionMapper {

    /**
     * 查询单个会议收藏状态
     * */
    @Select("SELECT collection_status FROM `bz_collection` WHERE user_id = #{user_id} AND meeting_id = #{meeting_id};")
    String selectCollectionStatusByUserIdAndMeetingId(@Param("user_id") int user_id,@Param("meeting_id") Long meeting_id);

    @Insert("INSERT INTO bz_collection(user_id,meeting_id,collection_time) VALUES(#{user_id},#{meeting_id},#{collection_time})")
    int insertCollectMeeting(@Param("user_id") int user_id,@Param("meeting_id") int meeting_id,@Param("collection_time") String collection_time);

    @Select("SELECT collection_id from bz_collection where user_id = #{user_id} AND meeting_id = #{meeting_id};")
    String selectCollection(@Param("user_id") int user_id,@Param("meeting_id") int meeting_id);

    @Update("UPDATE bz_collection SET collection_status = #{collection_status} , collection_time = #{collection_time} WHERE collection_id = #{collection_id};")
    int updateCollectionStatus(@Param("collection_id") String collection_id,@Param("collection_status") int collection_status,@Param("collection_time") String collection_time);

    /**
     * 得到我收藏的会议Id信息
     * */
    @Select("SELECT meeting_id,collection_time from bz_collection WHERE  user_id = #{user_id} AND collection_status = 1 ORDER BY collection_time DESC;")
    List<MeetingCollection> selectCollectionIdAndTime(@Param("user_id") int user_id);
}
